package api

import (
	"fmt"
	"github.com/aceld/zinx/ziface"
	"github.com/aceld/zinx/znet"
	"zinx_game/protobuf/proto_go"
	"zinx_game/utils/message"
)

type PlayerApi struct {
	znet.BaseRouter
	Nickname string
	UserCode uint32
	Gold     uint
}

func (p *PlayerApi) Handle(request ziface.IRequest) {
	msgId := request.GetMsgID()
	data := string(request.GetData())
	fmt.Printf("msg:%v data:%v", msgId, data)
	request.GetConnection().SendMsg(2, []byte("hello wold 222"))

	msg := &proto_go.Player{
		Id:       "1",
		Username: "2",
		Score:    0,
		Level:    0,
	}
	data1, _ := message.EncodeMessage(proto_go.MessageID_MSG_NONE, msg)

	request.GetConnection().SendMsg(2, data1)
}
